import request from '../util/http.js'

const path = [
	{
		"getAll": "ise7sInspect/7sInspect",
		"write": "ise7sInspect/ise7sUpdate",
		"getbyid": "",
		"upDate": "ise7sInspect/ise7sUpdate"
	},
	{
		"getAll": "iseTeachInspect/teachInspect",
		"write": "iseTeachInspect/iseTeachInspect",
		"getbyid": "",
		"upDate": "iseTeachInspect/iseTeachInspect"
	},
	{
		"getAll": "iseStudyInspect/studyInspect",
		"write": "iseStudyInspect/iseStudyInspect",
		"getbyid": "",
		"upDate": "iseStudyInspect/iseStudyInspect"
	},
	{
		"getAll": "iseDormInspect/dormInspect",
		"write": "iseDormInspect/iseDormInspect",
		"getbyid": "",
		"upDate": "iseDormInspect/iseDormInspect"
	},
]

export const httpCheck = async (type,describe,parmes,method = "GET") => {
	const url = path[type][describe];
	let par = parmes;
	if(describe == ("write" || "upDate") ){
		switch (type){
			case 0:
				par = { ...check7sRes,...info}; break;
			case 1:
				par = { ...teachRes,...info}; break;
			case 2:
				par = { ...studyRes,...info}; break;
			case 3:
				par = { ...dromRes,...info}; break;
			default:
				break;
		}
	}
	return await request(url,par,method);
}

export const check7sRes = {
    "arrange": false, //整理
    "clear": false,   //清扫
    "economize": false, //节约
    "feedback": false,
    "id": 0,
    "image": "string",
    "praise": false, //表扬
    "rectify": false, //整顿
    "remarks": "string",
    "repair": false, //保修
    "requires": "string",
    "safe": false,  //安全
    "teacherNumbers": [
        "string"
    ]
}

export const teachRes = {
    "chat": false,
    "discipline": false,
    "eat": false,
    "feedback": false,
    "holiday": 0,
    "id": 0,
    "image": "string",
    "late": 0,
    "lateLeave": false,
    "noBook": false,
    "noClothes": false,
    "noInteract": false,
    "noWrite": false,
    "play": false,
    "playPhone": false,
    "ppt": false,
    "remarks": "string",
    "requires": "string",
    "sit": false,
    "sleep": false,
    "stuOther": "string",
    "teaOther": "string",
    "teacherNumbers": [
        "string"
    ],
    "truancy": 0
}
export const studyRes = {
    "feedback": false,
    "id": 0,
    "image": "string",
    "privateHoliday": 0,
    "publicHoliday": 0,
    "remarks": "string",
    "requires": "string",
    "studyState": 0,
    "teacherNumbers": [
        "string"
    ],
    "truancy": 0
}
export const dromRes = {
    "balcony": false, //阳台炸物
    "bed": false, //被子
    "bottle": false, //酒瓶子
    "clothes": false, //衣物
    "desk": false, //坐面
    "electrical": false, //大功率
    "feedback": false, 
    "floor": false, //地面不好
    "id": 0,
    "image": "string",
    "knife": false, //刀
    "night": false, //夜不归属
    "pentrough": false, //水沟
    "pet": false,//宠物
    "remarks": "string",
    "requires": "string",
    "teacherNumbers": [
        "string"
    ],
    "toilet": false//方便面
}
//获取检查信息get，为填写检查信息
export const getCheckise7sInspect = (pageInfo, method) => request('ise7sInspect/7sInspect', pageInfo, method);
export const getCheckTeachInspect = (pageInfo, method) => request('iseTeachInspect/teachInspect', pageInfo, method);
export const getCheckdormInspect = (pageInfo, method) => request('iseDormInspect/dormInspect', pageInfo, method);
export const getiseStudyInspect = (pageInfo, method) => request('iseStudyInspect/studyInspect', pageInfo, method);


//获取已填写检查信息
export async function getcheckInfoByid(type, id){
	let result = null;
	switch(+type){
		case 0: result = await request('ise7sInspect/detail7sInspect/'+id); break
		case 1: result = await request('iseTeachInspect/detailTeachInspect/'+id); break
		case 2: result = await request('iseStudyInspect/detailStudyInspect/' + id); break
		case 3: result = await request('iseDormInspect/detailDormInspect/' + id); break
	}
	return result
}

export async function putcheckInfoByid(type, info){
	let result = null,pamers;
	switch(+type){
		case 0: pamers = {...check7sRes,...info};console.log(pamers); result = await request('ise7sInspect/ise7sUpdate',pamers,"PUT"); break
		case 1: pamers = {...teachRes,...info}; result = await request('iseTeachInspect/iseTeachInspect',pamers,"PUT"); break
		case 2: pamers = {...studyRes,...info}; result = await request('iseStudyInspect/iseStudyInspect', pamers,"PUT"); break
		case 3: pamers = {...dromRes,...info}; result = await request('iseDormInspect/iseDormInspect',pamers,"PUT"); break
	}
	return result
}



//检查进度
export async function progress(){
	const getCheckise7sInspectProgress =  () => request('ise7sInspect/7sInspectProgress');
	const getstudyInspectProgress = () => request('iseTeachInspect/studyInspectProgress');
	const getCheckise7sInmmpspectProgress = () => request('iseDormInspect/dormInspectProgress');
	const getdormInspectProgress = () => request('iseDormInspect/dormInspectProgress');
	return [await getCheckise7sInspectProgress(),await getstudyInspectProgress(),await getCheckise7sInmmpspectProgress(),await getdormInspectProgress()]
}
//检查反馈
export const getCheckise7sInspectFeedbacks = (pageInfo) => request('ise7sInspect/feedback7s', pageInfo);
export const getfeedbackTeach = (pageInfo) => request('ise7sInspect/feedbackTeach', pageInfo);
export const getfeedbackStudy = (pageInfo) => request('ise7sInspect/feedbackStudy', pageInfo);
export const getfeedbackDorm = (pageInfo) => request('ise7sInspect/feedbackDorm', pageInfo);
